import java.util.*;

public class Anagram
{	

	public static String simplifyString( String input )
	{
		input = input.trim();
		
		return ( input.toLowerCase().replaceAll("\\s", "") );
	}
	
	public static int[] getArrayOfIntegers(String input)
	{
		int length = input.length();
		int[] array = new int[length];
		
		for(int i = 0; i < length; i++)
		{
			array[i] = input.codePointAt(i);
		}
		return array;
	}
	
	public static boolean isAnagrams(String input1, String input2)
	{	
		if ( input1.length() != input2.length() ) return false;
		
		int[] arrayWithCodes1 = getArrayOfIntegers( input1 );
		int[] arrayWithCodes2 = getArrayOfIntegers( input2 );
		
		Arrays.sort(arrayWithCodes1);
		Arrays.sort(arrayWithCodes2);
			
		return (Arrays.equals(arrayWithCodes1,arrayWithCodes2));
	}
	public static void main(String[] args)
	{
		Scanner inputScanner = new Scanner( System.in );
		
		String firstPhrase;
		String secondPhrase;
		
		System.out.println("Type the first phrase:");
		firstPhrase = simplifyString( inputScanner.nextLine() );
		
		System.out.println("Type the second phrase:");
		secondPhrase = simplifyString( inputScanner.nextLine() );
		
		if ( isAnagrams(firstPhrase,secondPhrase) )
		{
			System.out.println("Input phrases are anagrams");
		}
		else
		{
			System.out.println("Input phrases can't be anagrams");
		}
		
		inputScanner.close();
	}
}